package com.okbihuo.perm.modules.common.rest;

import com.okbihuo.perm.constants.CacheKey;
import com.okbihuo.perm.core.tool.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static com.okbihuo.perm.constants.CacheKey.myProduct;


@RestController
@RequestMapping("open/common/clearCaChe")
@RequiredArgsConstructor
@Api(value = "系统设置", tags = "系统设置接口")
public class OpenClearCacheController {


    @ApiOperation(value = "清除所有缓存")
    @RequestMapping("clearCacheAll")
    public String clearCacheController() {
        clearMyProductCacheAll();
        clearRwbUserCacheAll();
        clearGzhUserCacheAll();
        clearSystemSettingCacheAll();
        return R.data("ok").toJSON();
    }


    @ApiOperation(value = "根据code值清除缓存")
    @RequestMapping("clearCacheByCode")
    public String clearCacheController(@RequestParam("code")String code) {
        clearSystemSettingCache(code);
        clearRwbUserCache(code);
        clearMyProductCache(code);
        return R.data("ok").toJSON();
    }


    @CacheEvict(value = CacheKey.systemSetting,key = "#code")
    public void clearSystemSettingCache(String code){

    }
    @CacheEvict(value = CacheKey.systemSetting,allEntries = true)
    public void clearSystemSettingCacheAll(){

    }
    @CacheEvict(value = CacheKey.gzhUser,allEntries = true)
    public void clearGzhUserCacheAll(){

    }

    @CacheEvict(value =CacheKey.rwbUser,key = "#code")
    public void clearRwbUserCache(String code){

    }

    @CacheEvict(value =CacheKey.rwbUser,allEntries = true)
    public void clearRwbUserCacheAll(){

    }

    @CacheEvict(value = myProduct,key = "#code")
    public void clearMyProductCache(String code){

    }

    @CacheEvict(value = myProduct,allEntries = true)
    public void clearMyProductCacheAll(){

    }


}
